package com.wlanauth.web.core;


import java.util.Collection;
import java.util.Map;

/**
 * 
 * @author zz 2011-3-18
 * 
 */
public class JsonResult {

	private static final long serialVersionUID = 1L;
	private final Map<?, ?> reqParams;
	
	public static boolean SUCCESS = true;
	public static boolean FAILURE = false;

	private Collection<?> rows;
	private Object data;
	private boolean success;
	public JsonResult(BaseActionSupport action,boolean success) {
		this(action,null,success);
		
	}


	public JsonResult(BaseActionSupport action, Object data, boolean success) {
		this.success = success;
		if(data!=null&&Collection.class.isAssignableFrom(data.getClass())){
			this.rows = (Collection<?>) data;
		} else {
			this.data = data;
		}
		this.reqParams = action.request.getParameterMap();
	}
	public JsonResult(BaseActionSupport action, Collection<?> data,Long total) {
		this.success = true;
		this.rows = data;
	
		this.data = total;
		this.reqParams = action.request.getParameterMap();
	}
	
	public Collection<?> getRows() {
		return rows;
	}

	public void setRows(Collection<?> rows) {
		this.rows = rows;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}


	public Map<?, ?> getReqParams() {
		return reqParams;
	}

}
